﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ibba.agil.core.common;


namespace ibba.agil.core
{
    public enum LogicalOperator
    {
        AND   = 1,
        OR    = 2,
        IN    = 3
    }

    public enum LogicalComparator
    {
        LIKE = 1,
        EQUAL = 2
        //MORE_THAN = 3,
        //MINUS_THAN = 4
    }

    /// <summary>
    /// Criteria de pesquisa utilizada em conjunto com %
    /// </summary>

    public enum LikePattern
    {
        Right = 1,
        Left = 2,
        Both = 3
    }

    /// <summary>
    /// Classe / Objecto generico de pesquisa para montagem de coleções no Banco de Dados
    /// </summary>

    public class CriteriaInfo
    {
        public object EntityData { get; set; }
        public string NameProperty { get; set; }
        public LogicalOperator LogicalType { get; set; }
        public LogicalComparator SearchType { get; set; }
        public LikePattern LikePattern { get; set; }

        public delegate Criteria<CriteriaInfo, object> Criteria();
    }


    public class Criteria<C, O> : Dictionary<C,O> 
        where C : CriteriaInfo

    {
        public object EntityData { get; set; }

        public Criteria() { }

        public Criteria(IDataEntity entity) {
            EntityData = entity;
        }
    }
}
